package com.example.applets.util;

import java.util.ArrayList;
import java.util.List;

public class PageUtil<T> {
    private List<T> datas = new ArrayList<>();
    private int totalPages;
    private int pageNo = 1;// 页号

    public PageUtil() {
    }

    public PageUtil(List<T> datas, int totalPages, int pageNo) {
        this.datas = datas;
        this.totalPages = totalPages;
        this.pageNo = pageNo;
    }

    public List<T> getDatas() {
        return datas;
    }

    public void setDatas(List<T> datas) {
        this.datas = datas;
    }

    public int getTotalPages() {
        return totalPages;
    }

    public void setTotalPages(int totalPages) {
        this.totalPages = totalPages;
    }

    public int getPageNo() {
        return pageNo;
    }

    public void setPageNo(int pageNo) {
        this.pageNo = pageNo;
    }


    public static int toTotalPage(int lines, int pageSize) {
        return lines / pageSize + (lines % pageSize == 0 ? 0 : 1);
    }
}
